package pe.gob.foncodes.ssa.bs.seguridad.domain;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author aespinoza
 */
@Entity
@Table(name = "ZONAL_ACTIVA", catalog = "", schema = "GEN")
@NamedQueries({
    @NamedQuery(name = "ZonalActiva.findAll", query = "SELECT z FROM ZonalActiva z"),
    @NamedQuery(name = "ZonalActiva.findByCodZonal", query = "SELECT z FROM ZonalActiva z WHERE z.codZonal = :codZonal")
})
public class ZonalActiva implements Serializable {
    private static final long serialVersionUID = 1L;
    private String codZonal;
    private Zonal zonal;

    public ZonalActiva() {
    }

    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "COD_ZONAL", nullable = false, length = 2)
    public String getCodZonal() {
        return codZonal;
    }

    public void setCodZonal(String codZonal) {
        this.codZonal = codZonal;
    }

    @JoinColumn(name = "COD_ZONAL", referencedColumnName = "COD_ZONAL", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false)
    public Zonal getZonal() {
        return zonal;
    }

    public void setZonal(Zonal zonal) {
        this.zonal = zonal;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codZonal != null ? codZonal.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ZonalActiva)) {
            return false;
        }
        ZonalActiva other = (ZonalActiva) object;
        if ((this.codZonal == null && other.codZonal != null) || (this.codZonal != null && !this.codZonal.equals(other.codZonal))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.gob.foncodes.ssa.bs.seguridad.domain.ZonalActiva[ codZonal=" + codZonal + " ]";
    }
    
}
